#pragma once
#include <vector>
#include <string>
#include <chrono>
#include "CLogRecord.h"

class CTableBase;

class CUploadBatch
{
public:
	CUploadBatch();
	~CUploadBatch();

	std::string getBatchId() const;
	void SetTableName(const std::string& tableName);
	const std::string& GetTableName() const;

	virtual void AddRecord(const CLogRecordPtr& record);
	const std::vector<CLogRecordPtr>& GetRecords() const;

	void SetMaxCursor(uint64_t nMaxCursor);
	uint64_t GetMaxCursor() const;

	void SetTimeOutIntervalSeconds(int timeOutIntervalSeconds);

	virtual void addFailedCount();
	int getFailedCount() const;

	// Upload status management
	void setUploadStartTime();
	bool isUploading() const;
	void setUploading(bool uploading);
	
	// Retry management
	int getRetryCount() const;
	void incrementRetryCount();
	void resetRetryCount();
	
	// Timeout check
	bool isTimedOut() const;

private:
	std::string m_tableName, m_batchId;
	std::vector<CLogRecordPtr> m_records;
	uint64_t m_nMaxCursor;
	int m_nFailedCount;
	time_t m_startTime;
	int m_timeOutIntervalSeconds;
	// Upload status
	time_t m_uploadStartTime;
	bool m_isUploading;
	int m_retryCount;
};

typedef std::shared_ptr<CUploadBatch> CUpLoadBatchPtr;

